{include file=member.header.html}
{$images_upload}
{$editor_upload}
{$build_editor}
<style>
.box_arr .table_btn { width: 222px; }
.box_arr .table_btn a { float: left; }
.box_arr .table_btn a.disable_spec { background: url({res file=images/member/btn.gif}) repeat 0 -1018px; float: right; }
.add_spec .add_link { color:#919191; }
.add_spec .add_link:hover { color:red; }
add_spec h2 { padding-left: 10px; }
.width7{ width: 250px;}
.f_l{ float:left; }
.mls_id { width: 0; filter: alpha(opacity=0);opacity: 0; }
</style>
<script type="text/javascript">
//<!CDATA[
var SPEC = {$goods.spec_json};


function add_uploadedfile(file_data)
{
    if(file_data.instance == 'goods_image'){
        $('#goods_images').append('<li ectype="handle_pic" file_id="'+ file_data.file_id +'" thumbnail="{$site_url}/'+ file_data.thumbnail +'"><input type="hidden" value="'+ file_data.file_id +'" name="goods_file_id[]"/><div class="pic"><img src="{$site_url}/'+ file_data.thumbnail +'" width="100" height="100" alt="" /><div ectype="handler" class="bg"><p class="operation"><span class="cut_in" ectype="set_cover" ecm_title="{$lang.set_cover}"></span><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p></div></div></li>');
                trigger_uploader();
        if($('#big_goods_image').attr('src') == '{$goods.default_goods_image}'){
            set_cover(file_data.file_id);
        }
        if(GOODS_SWFU.getStats().files_queued == 0){
            window.setTimeout(function(){
                $('#uploader').hide();
                $('#open_uploader').find('.show').attr('class','hide');
            },4000);
        }
    }else if(file_data.instance == 'desc_image'){
        $('#desc_images').append('<li file_name="'+ file_data.file_name +'" file_path="'+ file_data.file_path +'" ectype="handle_pic" file_id="'+ file_data.file_id +'"><input type="hidden" name="desc_file_id[]" value="'+ file_data.file_id +'"><div class="pic" style="z-index: 2;"><img src="{$site_url}/'+ file_data.file_path +'" width="80" height="80" alt="'+ file_data.file_name +'" /></div><div ectype="handler" class="bg" style="z-index: 3;display:none"><img src="{$site_url}/'+ file_data.file_path +'" width="80" height="80" alt="'+ file_data.file_name +'" /><p class="operation"><a href="javascript:void(0);" class="cut_in" ectype="insert_editor" ecm_title="{$lang.insert_editor}"></a><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p><p class="name">'+ file_data.file_name +'</p></div></li>');
                trigger_uploader();
        if(EDITOR_SWFU.getStats().files_queued == 0){
            window.setTimeout(function(){
                $('#editor_uploader').hide();
            },5000);
        }
    }
}


function set_cover(file_id){
    if(typeof(file_id) == 'undefined'){
        $('#big_goods_image').attr('src','{$goods.default_goods_image}');
        return;
    }
    var obj = $('*[file_id="'+ file_id +'"]');
    $('*[file_id="'+ file_id +'"]').clone(true).prependTo('#goods_images');
    $('*[ectype="handler"]').hide();
    $('#big_goods_image').attr('src',obj.attr('thumbnail'));
    obj.remove();
}

$(function(){
     $('#goods_form').validate({
        errorPlacement: function(error, element){
            $(element).next('.field_notice').hide();
            $(element).after(error);
        },
        success       : function(label){
            label.addClass('validate_right').text('OK!');
        },
        onkeyup : false,
        rules : {
            goods_name : {
                required   : true
            },
            price      : {
                number     : true,
                required : true,
                min : 0
            },
            stock      : {
                digits    : true
            },
			<!-- integral psmb -->
			max_exchange : {
				digits : true,
				min    : 0
			},
			<!-- end -->

            cate_id    : {
                remote   : {
                    url  : 'index.php?app=my_goods&act=check_mgcate',
                    type : 'get',
                    data : {
                        cate_id : function(){
                            return $('#cate_id').val();
                        }
                    }
                }
            }
        },
        messages : {
            goods_name  : {
                required   : '{$lang.goods_name_empty}'
            },
            price       : {
                number     : '{$lang.number_only}',
                required : '{$lang.price_empty}',
                min : '{$lang.price_ge_0}'
            },
            stock       : {
                digits  : '{$lang.number_only}'
            },
			<!-- integral psmb -->
			max_exchange : {
				digits : '{$lang.number_only}',
				min    : '{$lang.exchange_number_ge0}'
			},
			<!-- end -->
            cate_id     : {
                remote  : '{$lang.select_leaf_category}'
            }
        }
    });
    // init cover
    set_cover($("#goods_images li:first-child").attr('file_id'));

    // init spec
    spec_update();
});
//]]>
</script>
<div class="content">
  <div class="totline"></div>
  <div class="botline"></div>
  {include file=member.menu.html}
  <div id="right">
  	 	{include file=member.curlocal.html}
     	{include file=member.submenu.html}
        <div  class="wrap publish">
            <div class="public">
                <form method="post" id="goods_form">
					<div class="information_index">
                        <div class="add_spec" dialog_title="{$lang.edit}{$lang.specification}" ectype="dialog_contents" style="display: none">
                            <!--<form>-->
                            <p>{$lang.note_for_add_spec_popup}</p>
                            <div class="table" ectype="spec_editor">
                                <ul class="th">
                                    <li><input col="spec_name_1" type="text" class="text width4" /></li>
                                    <li><input col="spec_name_2" type="text" class="text width4" /></li>
                                    <li class="distance1">{$lang.price}</li>
                                    <li class="distance1">{$lang.stock}</li>
                                    <li class="distance2">{$lang.sku}</li>
                                    <li class="distance3">{$lang.handle}</li>
                                </ul>
                                <ul class="td" ectype="spec_item">
                                    <li><input item="spec_1" type="text" class="text width4" /></li>
                                    <li><input item="spec_2" type="text" class="text width4" /></li>
                                    <li><input item="price" type="text" class="text width4" /></li>
                                    <li><input item="stock" type="text" class="text width4" /></li>
                                    <li><input item="sku" type="text" class="text width8" /><input item="spec_id" type="hidden" /></li>
                                    <li class="padding3">
                                        <span ectype="up_spec_item" class="up_btn"></span>
                                        <span ectype="down_spec_item" class="down_btn"></span>
                                        <span ectype="drop_spec_item" class="delete_btn"></span>
                                    </li>
                                </ul>
                                <ul>
                                    <li class="add"><a href="javascript:;" ectype="add_spec_item" class="add_link">{$lang.add_spec_item}</a></li>
                                </ul>
                            </div>
                            <div class="btn_wrap"><input ectype="save_spec" type="submit" class="btn" value="{$lang.save_spec}" /></div>
                            <!--</form>-->
                        </div>   
                    </div>
					<h5 class="box-title">1.商品基本信息</h5>
					<ul class="box-body">
						<li class="subbox clearfix">
							<label class="subbox-title">商品类目：</label>
							<div class="subbox-body">
								<!--{foreach from=$publish_gcategory item=item name=fe_item}-->
								<!--{if !$smarty.foreach.fe_item.first}--> > <!--{/if}-->
								<span class="border-field">{$item.cate_name}</span>
								<!--{/foreach}-->
								<!--{if $smarty.get.act eq 'edit'}-->
								<a class="btn-gedit" href="{url app=my_goods&act=publish&id=$smarty.get.id}">编辑类目</a>
								<!--{else}-->
								<a class="btn-gedit" href="{url app=my_goods&act=add}">编辑类目</a>
								<!--{/if}-->
								<input type="text" id="cate_id" name="cate_id" value="{$goods.cate_id}" class="mls_id" />
                                <input type="hidden" name="cate_name" value="{$goods.cate_name|escape}" class="mls_names" />
							</div>
						</li>
						<li class="subbox clearfix">
							<label class="subbox-title">商品标题：</label>
							<div class="subbox-body"><input style="width:500px;" type="text" name="goods_name" value="{$goods.goods_name|escape}" class="text width_normal" /></div>
						</li>
						<!--{if $prop_list}-->
						<li class="subbox clearfix">
							<label class="subbox-title">商品属性：</label>
							<div class="subbox-body">
                        		<div id="props">
                           			{foreach from=$prop_list item=prop}
                          			<dl class="clearfix">
                          				<dt class="float-left">{$prop.name}{$lang.colon}</dt>
                          				<dd class="float-left">
                          				<!--{if $prop.prop_type eq 'checkbox' || $prop.prop_type eq 'radio'}-->
                          				{foreach from=$prop.value item=item}
                          				<label><input type="{$prop.prop_type}" name="props[]" value="{$item.pid}:{$item.vid}" {if $item.selected} checked="checked"{/if} /> 
                                        {if $prop.is_color_prop}<i {if $item.color_value}style="background:{$item.color_value}"{else}class="duocai"{/if}></i>{/if}
                                        {$item.prop_value}
										</label>
                          				{/foreach}
                                        <!--{else}-->
                          				<select name="props[]">
                             				<option value=""></option>
                             				{foreach from=$prop.value item=item}
                             				<option value="{$item.pid}:{$item.vid}" {if $item.selected} selected="selected"{/if}>{$item.prop_value}</option>
                             				{/foreach}
                          				</select>
                          				<!--{/if}-->
                         				</dd>
                           			</dl>
                          			{/foreach}
                        		</div>
								<div class="notice-word mt5"><p style="margin-bottom:0;">填错宝贝属性，可能会引起宝贝下架，影响您的正常销售。请认真准确填写</p></div>
							</div>
						</li>
						<!--{/if}-->
						
						<li class="subbox clearfix">
							<label class="subbox-title">商品品牌：</label>
							<div class="subbox-body">
								<select name="brand">
									<option value="">{$lang.select_pls}</option>
									<!--{foreach from=$brand_list item=item}-->
									<option value="{$item.brand_name|escape}" {if $goods.brand eq $item.brand_name} selected="selected"{/if}>{$item.brand_name|escape}</option>
									<!--{/foreach}-->
								</select>
							</div>
						</li>
						
						
						<li class="subbox clearfix"  ectype="no_spec">
							<label class="subbox-title">商品价格：</label>
							<div class="subbox-body">
								<input name="spec_id" value="{$goods._specs.0.spec_id}" type="hidden" />
								<input name="price" value="{$goods._specs.0.price}" type="text" class="text width_short" />
							</div>
						</li>
						<!--{if $integral_enabled}-->
						<li class="subbox clearfix"  ectype="max_exchange">
							<label class="subbox-title">积分抵扣：</label>
							<div class="subbox-body">
								<input name="max_exchange" value="{$goods.max_exchange}" type="text" class="text width_short" />
								<span class="gray">{$lang.rechange_price_note}</span>
							</div>
						</li>
						<!--{/if}-->
						
						<li class="subbox clearfix">
							<label class="subbox-title">商品规格：</label>
							<div class="subbox-body">
								<div class="arrange">
     								<div class="box_arr" ectype="no_spec"  style="display: none;">
         								<p class="pos_btn"><a ectype="add_spec" href="javascript:;" class="add_btn">{$lang.enable_spec}</a></p>
                                  		<p class="pos_txt">{$lang.note_for_add_spec}</p>
                     				</div>
                                  	<div class="box_arr has_spec" ectype="has_spec"  style="display: none;">
                      					<table ectype="spec_result">
                     						<tr>
                                 				<th col="spec_name_1">loading..</th>
                                               	<th col="spec_name_2">loading..</th>
                                          		<th col="price">{$lang.price}</th>
                                            	<th col="stock">{$lang.stock}</th>
                                          		<th col="sku">{$lang.sku}</th>
                             				</tr>
                                			<tr ectype="spec_item" style="display:none">
                                        		<td item="spec_1"></td>
                                           		<td item="spec_2"></td>
                                                <td item="price"></td>
                                           		<td item="stock"></td>
                                       			<td item="sku"></td>
                                        	</tr>
                                       	</table>
                                     	<p class="table_btn">
                                      		<a ectype="edit_spec" href="javascript:;" class="add_btn edit_spec">{$lang.edit_spec}</a>
                                        	<a ectype="disable_spec" href="javascript:;" class="add_btn disable_spec">{$lang.disable_spec}</a>
                             			</p>
                             		</div>
                 				</div>  
							</div>
						</li>
						
						<li class="subbox clearfix"  ectype="no_spec">
							<label class="subbox-title">商品库存：</label>
							<div class="subbox-body">
								<input name="stock" value="{$goods._specs.0.stock}" type="text" class="text width_short" />
							</div>
						</li>
						
						<li class="subbox clearfix"  ectype="no_spec">
							<label class="subbox-title">商品货号：</label>
							<div class="subbox-body">
								<input name="sku" value="{$goods._specs.0.sku}" type="text" class="text width_normal" />
							</div>
						</li>
					</ul>
					<h5 class="box-title">2.商品图片及描述</h5>
						<ul class="box-body">
							<li class="subbox clearfix">
								<label class="subbox-title">商品图片：</label>
								<div class="subbox-body">
									<div class="multimage-wrapper">
										<ul class="multimage-tabs clearfix">
											<li class="selected">本地上传</li>
											<!--<li>图片空间</li>-->
										</ul>
										<div class="multimage-panels clearfix">
											<div class="upload_btn">
                                    			<div class="btn-upload-image" id="open_uploader"><b class="hide">{$lang.upload_goods_image}</b></div>
                                   				<div class="upload_con" id="uploader" style="display:none" >
                                        			<div class="upload_con_top"></div>
                                        			<div class="upload_wrap">
                                           				<ul>
                                                			<li class="btn1">
                                               					<div id="divSwfuploadContainer">
                                                    				<div id="divButtonContainer">
                                                        				<span id="spanButtonPlaceholder"></span>
                                                   					</div>
                                                				</div>
                                                			</li>
                                               				<li><iframe src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}&instance=goods_image" width="86" height="30" scrolling="no" frameborder="0"></iframe></li>
                                                			<li id="open_remote" class="btn2">{$lang.rem_upload}</li>
                                            			</ul>
                                           				<div id="remote" class="upload_file" style="display:none">
                                            				<iframe src="index.php?app=comupload&act=view_remote&id={$id}&belong={$belong}&instance=goods_image" width="272" height="39" scrolling="no" frameborder="0"></iframe>
                                           				</div>
                                            			<div id="goods_upload_progress"></div>
                                        			</div>
                                        			<div class="upload_con_bottom"></div>
                                    			</div>
                                			</div>
											<div class="text">{$lang.note_for_upload}</div>
										</div>
										<div class="multimage-piclist clearfix">
                                			<div class="small_pic">
                                   				<ul id="goods_images">
                                        			<!--{foreach from=$goods_images item=goods_iamge}-->
                                        			<li ectype="handle_pic" file_id="{$goods_iamge.file_id}" thumbnail="{$site_url}/{$goods_iamge.thumbnail}">
                                        				<input type="hidden" name="goods_file_id[]" value="{$goods_iamge.file_id}">
                                        				<div class="pic">
                                           					<img src="{$site_url}/{$goods_iamge.thumbnail}" width="100" height="100" />
                                            				<div ectype="handler" class="bg">
                                                    			<p class="operation">
                                                        			<span class="cut_in" ectype="set_cover" ecm_title="{$lang.set_cover}"></span>
                                                        			<span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span>
                                                    			</p>
                                           					</div>
                                        				</div>
                                        			</li>
                                       				<!--{/foreach}-->
                                    			</ul>
                                    			<div class="clear"></div>
                                			</div>
											<div class="notice-word" style="margin-right:14px;"><p class="yellow">注：第一张为商品主图，也即是在前台页面显示。将鼠标移至图片上可以调整顺序。</p></div>
										</div>
									</div>								
								</div>
							</li>
							<li class="subbox clearfix">
								<label class="subbox-title">{$lang.description}：</label>
								<div class="subbox-body">
                            		<div class="add_wrap">
                               			<div class="editor">
                                    		<div>
                                    			<textarea name="description" id="description"  style="width:713px; height:400px;">
                                    			{$goods.description|escape}
                                    			</textarea>
                                    		</div>
											<div class="multimage-wrapper descimage-wrapper">
												<ul class="multimage-tabs clearfix">
													<li class="selected">插入描述图片</li>
												</ul>
											<div class="multimage-panels clearfix">
												<div style=" position: relative; top: 10px; z-index: 5;">
													<a class="btn-upload-image" id="open_editor_uploader"><b>{$lang.uploadedfile}</b></a>
                                       				<div class="upload_con" id="editor_uploader" style="display:none">
                                            			<div class="upload_con_top"></div>
                                           				<div class="upload_wrap">
                                                			<ul>
                                                    			<li>
                                                        			<div id="divSwfuploadContainer">
                                                            			<div id="divButtonContainer">
                                                                			<span id="editor_upload_button"></span>
                                                           				</div>
                                                        			</div>
                                                    			</li>
                                                   				<li><iframe src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}&instance=desc_image" width="86" height="30" scrolling="no" frameborder="0"></iframe></li>
                                                    			<li id="open_editor_remote" class="btn2">{$lang.rem_upload}</li>
                                               				</ul>
                                                			<div id="editor_remote" class="upload_file" style="display:none">
                                                				<iframe src="index.php?app=comupload&act=view_remote&id={$id}&belong={$belong}&instance=desc_image" width="272" height="39" scrolling="no" frameborder="0"></iframe>
                                                			</div>
                                                			<div id="editor_upload_progress"></div>
                                                     	</div>
                                           				<div class="upload_con_bottom"></div>
                                        			</div>
													<div class="text">{$lang.note_for_upload}</div>
                                    			</div>
											</div>
											<div class="multimage-piclist clearfix">
												<ul id="desc_images" class="preview J_descriptioneditor">
                                        			<!--{foreach from=$desc_images item=desc_image}-->
                                        			<li ectype="handle_pic" file_name="{$desc_image.file_name|escape}" file_path="{$desc_image.file_path}" file_id="{$desc_image.file_id}">
                                        				<input type="hidden" name="desc_file_id[]" value="{$desc_image.file_id}">
                                            			<div class="pic">
                                            				<img src="{$site_url}/{$desc_image.file_path}" width="80" height="80" alt="{$desc_image.file_name|escape}" title="{$desc_image.file_name|escape}" />
														</div>
                                            			<div ectype="handler" class="bg">
                                            				<img src="{$site_url}/{$desc_image.file_path}" width="80" height="80" alt="{$desc_image.file_name|escape}" title="{$desc_image.file_name|escape}" />
                                                			<p class="operation">
                                                    			<a class="cut_in" ectype="insert_editor" href="javascript:void(0);" ecm_title="{$lang.insert_editor}"></a>
                                                    			<span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span>
                                                			</p>
                                                			<p title="{$desc_image.file_name|escape}" class="name">{$desc_image.file_name|escape}</p>
                                            			</div>
                                        			</li>
                                        			<!--{/foreach}-->
                                    			</ul>
											</div>
											<!--{if $desc_images}-->
											<div class="notice-word" style="padding:14px;"><p class="yellow">插入方法：将鼠标移至需要插入的图片上面，然后点击插入按钮，即可将图片插入到编辑器中。</p>
											<!--{/if}-->
										</div>
                                	</div>
                            	</div>
							</div>
						</li>
						<!--{if $sgcategories}-->
						<li class="subbox clearfix">
							<label class="subbox-title">{$lang.sgcategory}：</label>
							<div class="subbox-body">
								<div class="shop-cat-list">
									<div class="shop-cat-each">
     									<!--{foreach from=$sgcategories item=sgcate}-->
										<p><label><input type="checkbox" name="sgcate_id[]" value="{$sgcate.cate_id}" {if $sgcate.selected} checked="checked"{/if} /> {$sgcate.cate_name}</label></p>
                                    		<!--{foreach from=$sgcate.children item=item}-->
											<p class="children-1"><label><input type="checkbox" name="sgcate_id[]" value="{$item.cate_id}" {if $item.selected} checked="checked"{/if}/> {$item.cate_name}</label></p>
											<!-- {/foreach} -->
										<!-- {/foreach} -->
									</div>
									
								</div>
							</div>
						</li>
						<!--{/if}-->
					</ul>
					<h5 class="box-title">3.物流及配送设置</h5>
					<ul class="box-body">
						<li class="subbox clearfix">
							<label class="subbox-title">{$lang.delivery_template}：</label>
							<div class="subbox-body">
								<select class="text" name="delivery_template_id">
									<!--{foreach from=$deliverys item=delivery name=fe_delivery}-->
									<option value="{$delivery.template_id}" {if $smarty.get.act eq 'add' && $smarty.foreach.fe_delivery.first} checked="checked" {elseif $goods.delivery_template_id==$delivery.template_id} selected="selected" {/if} >{$delivery.name}</option>
									<!--{/foreach}-->
								</select>
								<a href="{url app=my_delivery}" target="_blank" style="color:blue; text-decoration:none">{$lang.delivery_template_list}</a>           
							</div>
						</li>
					<h5 class="box-title">4.其他设置</h5>
					<ul class="box-body">
						<li class="subbox clearfix">
							<label class="subbox-title">商品上架：</label>
							<div class="subbox-body">
								<label><input name="if_show" value="1" type="radio" {if $goods.if_show}checked="checked" {/if}/> {$lang.yes}</label>
                                <label><input name="if_show" value="0" type="radio" {if !$goods.if_show}checked="checked" {/if}/> {$lang.no}</label>            
							</div>
						</li>
						
						<li class="subbox clearfix">
							<label class="subbox-title">商品推荐：</label>
							<div class="subbox-body">
								<label><input name="recommended" value="1" {if $goods.recommended}checked="checked" {/if}type="radio" /> {$lang.yes}</label>
                                <label><input name="recommended" value="0" {if !$goods.recommended}checked="checked" {/if}type="radio" /> {$lang.no}</label>
                                <span class="gray">{$lang.note_for_recommended}</span>           
							</div>
						</li>
						<li class="subbox clearfix">
							<label class="subbox-title">商品标签：</label>
							<div class="subbox-body"><input style="width:300px;" type="text" name="tags" value="{$goods.tags|escape}" class="text width_normal" /> <span class="gray">多个标签请用半角逗号隔开</span></div>
						</li>
					</ul>
                    
					<div class="issuance"><input type="submit" class="btn" value="{$lang.submit}" /></div>
                </form>
            </div>
        </div>
        <div class="clear"></div>
        <div class="adorn_right1"></div>
        <div class="adorn_right2"></div>
        <div class="adorn_right3"></div>
        <div class="adorn_right4"></div>
    </div>
    <div class="clear"></div>
</div>
{include file=footer.html}
